<html>
<head><meta charset="utf-8"><title>turning on MIR inlining · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html">turning on MIR inlining</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="135549284"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/135549284" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#135549284">(Oct 10 2018 at 15:33)</a>:</h4>
<p>Hi <span class="user-mention" data-user-id="116009">@nikomatsakis</span>, per our conversation on Discord, I've been trying to resurrect PR <a href="https://github.com/rust-lang/rust/issues/48602" target="_blank" title="https://github.com/rust-lang/rust/issues/48602">#48602</a>. It looks to me like <span class="user-mention" data-user-id="119009">@eddyb</span> was trying to get the code to build "enough" to get a perf run and see what the potential performance improvements might be. I've worked around a few more issues but I'm still getting ICEs when trying to build rustdoc.</p>
<p>Should I keep trying to just get a build out so we can measure the performance or should I try a more principled approach and try to actually fix the bugs rather than work around them? </p>
<p>Also, what's the best way to troubleshoot a broken stage2 compiler that ICEs? The stage1 compiler seems to work fine and can build rustdoc but the stage2 compiler ICEs when building it.</p>



<a name="135549304"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/135549304" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#135549304">(Oct 10 2018 at 15:33)</a>:</h4>
<p>I'd be inclined to fix the bugs first ;)</p>



<a name="135549317"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/135549317" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#135549317">(Oct 10 2018 at 15:33)</a>:</h4>
<p>though stage2 only bugs are definitely the worst kind</p>



<a name="135549416"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/135549416" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#135549416">(Oct 10 2018 at 15:35)</a>:</h4>
<p>what is the ICE? I don't really know a "magic bullet" to troubleshoot beyond trying to track down where it is failing; a stage2 error however could be the result of the stage1 compiler miscompiling the compiler itself, so the point where it fails might not itself be broken per se (e.g., maybe it is generating bad code due to inlining)</p>



<a name="135549432"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/135549432" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#135549432">(Oct 10 2018 at 15:35)</a>:</h4>
<p>given that hypothesis, one way to track down where the problem is would be to build on the "optimization fuel" stuff we have</p>



<a name="135549443"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/135549443" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#135549443">(Oct 10 2018 at 15:35)</a>:</h4>
<p>basically it would let you perform only the first N inlining attempts</p>



<a name="135549451"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/135549451" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#135549451">(Oct 10 2018 at 15:35)</a>:</h4>
<p>you can then bisect around with N to try and find <em>which</em> inlining goes wrong</p>



<a name="135549508"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/135549508" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#135549508">(Oct 10 2018 at 15:36)</a>:</h4>
<p>Uh, I don't have it handy unfortunately but it's a generic "you called .unwrap() on a None" type error.</p>



<a name="135549515"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/135549515" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#135549515">(Oct 10 2018 at 15:36)</a>:</h4>
<p>I think I remember the call site... let me see if I can find it</p>



<a name="135549610"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/135549610" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#135549610">(Oct 10 2018 at 15:38)</a>:</h4>
<p>sounds like the backtrace could be handy</p>



<a name="135549853"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/135549853" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#135549853">(Oct 10 2018 at 15:42)</a>:</h4>
<p>Hmm. I can't seem to find it offhand.</p>
<p>I'll post it tonight when I get back to my pc</p>



<a name="135549911"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/135549911" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#135549911">(Oct 10 2018 at 15:43)</a>:</h4>
<p>I <em>think</em> there's invalid inlining happening.</p>



<a name="135549935"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/135549935" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#135549935">(Oct 10 2018 at 15:43)</a>:</h4>
<p>I worked around another ICE by adding a <code>#[inline(never)]</code> to a trait method with a default body.</p>



<a name="135550051"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/135550051" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#135550051">(Oct 10 2018 at 15:45)</a>:</h4>
<p><span class="user-mention" data-user-id="125250">@Wesley Wiser</span> well that does give a pretty good clue then as to where the bugs are ;)</p>



<a name="135550054"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/135550054" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#135550054">(Oct 10 2018 at 15:45)</a>:</h4>
<p>maybe worth trying to fix that one that you worked around first</p>



<a name="135550061"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/135550061" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#135550061">(Oct 10 2018 at 15:45)</a>:</h4>
<p>in hopes that there is one underlying bug</p>



<a name="135550167"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/135550167" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#135550167">(Oct 10 2018 at 15:46)</a>:</h4>
<p>I guess I can dump the MIR by manually invoking the compiler for the appropriate crate and then passing <code>-Z dump-mir=</code> or whatever?</p>



<a name="135550179"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/135550179" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#135550179">(Oct 10 2018 at 15:47)</a>:</h4>
<p>To validate that it is a bad optimization</p>



<a name="135550414"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/135550414" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#135550414">(Oct 10 2018 at 15:51)</a>:</h4>
<p>yes, you can do that</p>



<a name="135550421"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/135550421" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#135550421">(Oct 10 2018 at 15:51)</a>:</h4>
<p>it is kind of a pain to invoke the compiler during the bootstrap cycle sometimes</p>



<a name="135550427"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/135550427" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#135550427">(Oct 10 2018 at 15:51)</a>:</h4>
<p>due to the extensive (and, to me, irritating) use of env vars</p>



<a name="135550473"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/135550473" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#135550473">(Oct 10 2018 at 15:52)</a>:</h4>
<p>I usually do <code>x.py build -vv</code></p>



<a name="135550485"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/135550485" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#135550485">(Oct 10 2018 at 15:52)</a>:</h4>
<p>right before the failing compile there is something like <code>rustc command: ...</code> followed by a <strong>super long</strong> line</p>



<a name="135550492"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/135550492" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#135550492">(Oct 10 2018 at 15:52)</a>:</h4>
<p>sometimes when you copy-and-paste that and run it from the <code>src</code> directory, it works</p>



<a name="135550494"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/135550494" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#135550494">(Oct 10 2018 at 15:52)</a>:</h4>
<p>other times...it doesn't</p>



<a name="135550502"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/135550502" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#135550502">(Oct 10 2018 at 15:52)</a>:</h4>
<p>if there's a better way, I'd like to know it :)</p>



<a name="135550512"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/135550512" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#135550512">(Oct 10 2018 at 15:53)</a>:</h4>
<p>but you can use <code>RUSTFLAGS=-Zdump-mir=...</code> etc and run <code>x.py</code>, too</p>



<a name="135550534"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/135550534" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#135550534">(Oct 10 2018 at 15:53)</a>:</h4>
<p>Ah, interesting. I always forget about that. Thanks!</p>



<a name="135550589"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/135550589" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#135550589">(Oct 10 2018 at 15:54)</a>:</h4>
<p>I guess if it's the issue I think is, I could probably just write a test that repro's the issue.</p>



<a name="135575579"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/135575579" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#135575579">(Oct 10 2018 at 23:48)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> The stack trace is:</p>
<div class="codehilite"><pre><span></span>Copying stage2 rustc from stage1 (x86_64-unknown-linux-gnu -&gt; x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
Building rustdoc for stage2 (x86_64-unknown-linux-gnu)
   Compiling libc v0.2.36
thread &#39;rustc&#39; panicked at &#39;called `Option::unwrap()` on a `None` value&#39;, libcore/option.rs:335:21
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::print
             at libstd/sys_common/backtrace.rs:71
             at libstd/sys_common/backtrace.rs:59
   2: std::panicking::default_hook::{{closure}}
             at libstd/panicking.rs:206
   3: std::panicking::default_hook
             at libstd/panicking.rs:222
   4: core::ops::function::Fn::call
             at librustc/util/common.rs:50
             at /home/wesley/code/rust/rust/src/libcore/ops/function.rs:73
   5: std::panicking::rust_panic_with_hook
             at libstd/panicking.rs:401
   6: std::panicking::begin_panic_fmt
             at libstd/panicking.rs:347
   7: rust_begin_unwind
             at libstd/panicking.rs:323
   8: core::panicking::panic_fmt
             at libcore/panicking.rs:71
   9: core::panicking::panic
             at libcore/panicking.rs:51
  10: syntax::ext::expand::MacroExpander::expand
             at /home/wesley/code/rust/rust/src/libcore/macros.rs:20
             at libsyntax/ext/expand.rs:307
  11: syntax::ext::expand::MacroExpander::expand_crate
             at libsyntax/ext/expand.rs:245
  12: rustc_driver::driver::phase_2_configure_and_expand_inner::{{closure}}
             at librustc_driver/driver.rs:795
  13: rustc::util::common::time
             at /home/wesley/code/rust/rust/src/librustc/util/common.rs:141
  14: rustc_driver::driver::phase_2_configure_and_expand
             at librustc_driver/driver.rs:754
             at librustc_driver/driver.rs:606
  15: rustc_driver::driver::compile_input
             at librustc_driver/driver.rs:129
  16: rustc_driver::run_compiler
             at librustc_driver/lib.rs:508

error: internal compiler error: unexpected panic
</pre></div>



<a name="135584105"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/135584105" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#135584105">(Oct 11 2018 at 03:47)</a>:</h4>
<p>There's definitely misoptimization going on. The following program prints <code>1</code> instead of <code>2</code> with MIR inlining turned on</p>
<div class="codehilite"><pre><span></span>fn main() {
    println!(&quot;{}&quot;, test(&amp;()));
}

fn test(x: &amp;X) -&gt; u32 {
    x.y()
}

trait X {
    fn y(&amp;self) -&gt; u32 {
        1
    }
}

impl X for () {
    fn y(&amp;self) -&gt; u32 {
        2
    }
}
</pre></div>


<p>I'm working on a fix for that.</p>



<a name="135607589"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/135607589" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#135607589">(Oct 11 2018 at 13:23)</a>:</h4>
<p>I do not remember being very pleased with the current state that our inliner is, even if I didn’t considered it to be buggy. It feels more like a PoC to me.</p>



<a name="135909736"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/135909736" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#135909736">(Oct 16 2018 at 16:01)</a>:</h4>
<p>Just to give a small status update: I'm still working on this. I pushed a fix for the virtual call inlining issue (<a href="https://github.com/rust-lang/rust/issues/55046" target="_blank" title="https://github.com/rust-lang/rust/issues/55046">#55046</a>) which has been merged. I'm now investigating another miscompilation which results in a very confounding backtrace:</p>
<div class="codehilite"><pre><span></span>[continues for another 209539 stack frames]
#209540 0x0000555555563236 in core::ptr::&lt;impl core::cmp::PartialOrd for *const T&gt;::partial_cmp ()
#209541 0x00005555555631a7 in core::ptr::&lt;impl core::cmp::Ord for *const T&gt;::cmp ()
#209542 0x0000555555563236 in core::ptr::&lt;impl core::cmp::PartialOrd for *const T&gt;::partial_cmp ()
#209543 0x00005555555631a7 in core::ptr::&lt;impl core::cmp::Ord for *const T&gt;::cmp ()
#209544 0x0000555555563236 in core::ptr::&lt;impl core::cmp::PartialOrd for *const T&gt;::partial_cmp ()
#209545 0x00005555555631a7 in core::ptr::&lt;impl core::cmp::Ord for *const T&gt;::cmp ()
#209546 0x0000555555564b4b in &lt;[A] as core::slice::SliceOrd&lt;A&gt;&gt;::compare ()
#209547 0x0000555555564a26 in core::slice::&lt;impl core::cmp::Ord for [T]&gt;::cmp ()
#209548 0x00005555555620be in core::array::&lt;impl core::cmp::Ord for [T; &lt;unevaluated[]&gt;]&gt;::cmp ()
#209549 0x0000555555561624 in raw_fat_ptr::main::{{closure}} ()
#209550 0x000055555556051d in alloc::slice::&lt;impl [T]&gt;::sort_by::{{closure}} ()
#209551 0x0000555555560028 in alloc::slice::insert_head ()
#209552 0x000055555555f0dd in alloc::slice::merge_sort ()
#209553 0x00005555555615b1 in raw_fat_ptr::main ()
#209554 0x0000555555562123 in std::rt::lang_start::{{closure}} ()
#209555 0x0000555555566168 in std::rt::lang_start_internal::{{closure}} () at libstd/rt.rs:59
#209556 std::panicking::try::do_call (data=0x7fffffffdd48 &quot;\240\335\377\377\377\177\000&quot;) at libstd/panicking.rs:305
#209557 0x000055555557b59f in __rust_maybe_catch_panic (f=0x0, data=0x7fffffffd758 &quot;\207\334\377\377\377\177\000&quot;, data_ptr=0x7fffffffdd58, vtable_ptr=0x7fffffffdd50) at libpanic_unwind/lib.rs:102
#209558 0x000055555556605a in std::panicking::try (f=...) at libstd/panicking.rs:284
#209559 0x000055555556efc0 in std::rt::lang_start_internal (main=..., argc=1, argv=0x7fffffffdf48) at libstd/panic.rs:361
#209560 0x0000555555562107 in std::rt::lang_start ()
#209561 0x000055555556165e in main ()
</pre></div>



<a name="135911481"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/135911481" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#135911481">(Oct 16 2018 at 16:30)</a>:</h4>
<p><span class="user-mention" data-user-id="125250">@Wesley Wiser</span> nice work on <a href="https://github.com/rust-lang/rust/issues/55046" target="_blank" title="https://github.com/rust-lang/rust/issues/55046">#55046</a>!</p>



<a name="135912702"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/135912702" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#135912702">(Oct 16 2018 at 16:50)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> Thanks!</p>



<a name="135912716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/135912716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#135912716">(Oct 16 2018 at 16:50)</a>:</h4>
<p>BTW, are you going to be at RBR this week?</p>



<a name="135912758"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/135912758" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#135912758">(Oct 16 2018 at 16:51)</a>:</h4>
<p>yes</p>



<a name="135912761"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/135912761" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#135912761">(Oct 16 2018 at 16:51)</a>:</h4>
<p>I arrive Thu night</p>



<a name="135912796"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/135912796" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#135912796">(Oct 16 2018 at 16:52)</a>:</h4>
<p>Cool! Looking forward to meeting you :)</p>



<a name="135961318"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/135961318" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#135961318">(Oct 17 2018 at 09:50)</a>:</h4>
<p><span class="user-mention" data-user-id="125250">@Wesley Wiser</span> might be worth also fixing <a href="https://github.com/rust-lang/rust/issues/50411" target="_blank" title="https://github.com/rust-lang/rust/issues/50411">https://github.com/rust-lang/rust/issues/50411</a> before enabling more MIR optimziations per default</p>



<a name="135961324"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/135961324" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#135961324">(Oct 17 2018 at 09:50)</a>:</h4>
<p>and <a href="https://github.com/rust-lang/rust/issues/52691" target="_blank" title="https://github.com/rust-lang/rust/issues/52691">https://github.com/rust-lang/rust/issues/52691</a> might also still be around</p>



<a name="135975239"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/135975239" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#135975239">(Oct 17 2018 at 14:14)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> Good idea! I'll definitely take a look into that. Right now I'm just trying to the compiler unbroken enough to see what the potential performance differences might be. I'm sure there's a lot of issues to solve before we can turn it on everywhere by default.</p>



<a name="135975578"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/135975578" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#135975578">(Oct 17 2018 at 14:20)</a>:</h4>
<p><span class="user-mention" data-user-id="125250">@Wesley Wiser</span> okay. :)  Great to see someone push this! miri has been sitting on these bugs since about forever.</p>



<a name="147623365"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/147623365" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#147623365">(Nov 13 2018 at 20:35)</a>:</h4>
<p>Status update: Still working on this :) Since the last update, I implemented optimization fuel for the inliner (<a href="https://github.com/rust-lang/rust/issues/55739" target="_blank" title="https://github.com/rust-lang/rust/issues/55739">#55739</a> thanks for the idea <span class="user-mention" data-user-id="116009">@nikomatsakis</span>!), fixed the optimization fuel code so it doesn't break Rustbuild (<a href="https://github.com/rust-lang/rust/issues/55495" target="_blank" title="https://github.com/rust-lang/rust/issues/55495">#55495</a> thanks <span class="user-mention" data-user-id="116083">@pnkfelix</span> for the assist with the test suite!), and found the other place we were inlining virtual function calls (<a href="https://github.com/rust-lang/rust/issues/55802" target="_blank" title="https://github.com/rust-lang/rust/issues/55802">#55802</a>). </p>
<p>At this point, with a small patch to always run the MIR inliner, the compiler will bootstrap successfully to stage 2 but there's quite a few test failures. <br>
In just the <code>run-pass</code> suite there are these failures:</p>
<div class="codehilite"><pre><span></span>    [run-pass] run-pass/associated-consts/associated-const-cross-crate-defaults.rs
    [run-pass] run-pass/associated-consts/associated-const-use-default.rs
    [run-pass] run-pass/backtrace-debuginfo.rs
    [run-pass] run-pass/cross-crate/xcrate_generic_fn_nested_return.rs
    [run-pass] run-pass/debuginfo-lto.rs
    [run-pass] run-pass/fat-lto.rs
    [run-pass] run-pass/generator/smoke.rs
    [run-pass] run-pass/issues/issue-11205.rs
    [run-pass] run-pass/lto-many-codegen-units.rs
    [run-pass] run-pass/lto-still-runs-thread-dtors.rs
    [run-pass] run-pass/optimization-fuel-0.rs
    [run-pass] run-pass/optimization-fuel-1.rs
    [run-pass] run-pass/panic-runtime/lto-abort.rs
    [run-pass] run-pass/panic-runtime/lto-unwind.rs
    [run-pass] run-pass/rfcs/rfc-2005-default-binding-mode/constref.rs
    [run-pass] run-pass/sepcomp/sepcomp-lib-lto.rs
    [run-pass] run-pass/stack-probes-lto.rs
    [run-pass] run-pass/ufcs-polymorphic-paths.rs
</pre></div>


<p>I'm currently trying to track down the next optimization issue (perhaps something to do with LTO?) by disabling inlining for a specific crate using the fuel flag (<code>RUSTFLAGS="-Z fuel={lib}=0" ./x.py test --stage 1</code>) but so far I've been unable to find the issue. </p>
<p>If anyone has any ideas, please feel free to leave a comment! Otherwise, I'll continue my search through the <code>rustc</code> crates looking for the culprit.</p>



<a name="147628572"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/147628572" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#147628572">(Nov 13 2018 at 21:58)</a>:</h4>
<p><span class="user-mention" data-user-id="125250">@Wesley Wiser</span> wow, nice</p>



<a name="147628583"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/147628583" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#147628583">(Nov 13 2018 at 21:58)</a>:</h4>
<p>which test are you trying to fix?</p>



<a name="147628588"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/147628588" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#147628588">(Nov 13 2018 at 21:58)</a>:</h4>
<p>those are all... interesting tests, they're the "scary ones" from my POV :)</p>



<a name="147628622"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/147628622" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#147628622">(Nov 13 2018 at 21:59)</a>:</h4>
<p>scary ones being cross-crate etc</p>



<a name="147628626"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/147628626" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#147628626">(Nov 13 2018 at 21:59)</a>:</h4>
<p>maybe run-pass/ufcs-polymorphic-paths.rs is not so bad</p>



<a name="147628653"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/147628653" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#147628653">(Nov 13 2018 at 21:59)</a>:</h4>
<p>that's probably the one I would start with...</p>



<a name="147629707"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20MIR%20inlining/near/147629707" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20MIR.20inlining.html#147629707">(Nov 13 2018 at 22:18)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> Any of them <span class="emoji emoji-263a" title="smile">:smile:</span> I've tried turning fuel off for a bunch of different crates but the same tests keep failing. (I've been tracking some notes here <a href="https://github.com/wesleywiser/rust/issues/2" target="_blank" title="https://github.com/wesleywiser/rust/issues/2">https://github.com/wesleywiser/rust/issues/2</a>)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>